﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RedHouse.Data.Service;
using RedHouse.Data.Base;
using RedHouse.Data.Entities;

namespace RedHouse.Web
{
    public partial class Speciaties : System.Web.UI.Page
    {
        private IDishService _dishService;
        private ICategoryService _categoryService;
        public List<RedHouseDish> Dishes { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            Initialize();
        }

        private void Initialize()
        {
            _dishService = new DishService();
            _categoryService = new CategoryService();
            RedHouseCategory category  = _categoryService.GetCategoryByName("Specialties");
            Dishes = _dishService.GetAllDishByCategory(category.Id);
            if (Session["location"] != null)
            {
                int location = int.Parse(Session["location"].ToString());
                Dishes = Dishes.Where(d => d.LocationID == location).ToList();
            }
            rptDish.DataSource = Dishes;
            rptDish.DataBind();
        }


        protected override void InitializeCulture()
        {
            string culture = Session["Culture"] == null ? "vi-VN" : Session["Culture"].ToString();

            if (culture != "Auto")
            {
                System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(culture);
                System.Threading.Thread.CurrentThread.CurrentCulture = ci;
                System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
            }
            base.InitializeCulture();
        }
    }
}